#ifndef OBJECT_H
#define OBJECT_H

#include <string>

#include "gamekit/gamekit.h"
#include "Table.h"
#include "Function.h"
#include "Thread.h"

struct lua_State;

namespace gamekit
{
	namespace scripting
	{
		enum ObjectType
		{
			TypeNone,
			TypeBoolean,
			TypeLightUserData,
			TypeNumber,
			TypeString,
			TypeTable,
			TypeFunction,
			TypeUserData,
			TypeThread
		};

		class Object
		{
			typedef unsigned int uint;

			friend class Arguments;

		public:
			~Object();

			ObjectType    getType(void) const;
			std::string   toString(void) const;
			bool          isNull(void) const;

			bool          asBoolean() const;
			double        asNumber() const;
			std::string   asString() const;
			Table         asTable() const;
			Function      asFunction() const;
			Thread        asThread() const;
			void*         asUserData(void) const;

			static Object Null(void);

		private:
			Object(lua_State* state, uint index);
			Object();



		private:
			lua_State* m_state;
			uint m_index;
			bool m_isNull;
			ObjectType m_type;
		};
	}
}

#endif
